home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / ultmtpch.lha / UPS / Sources / Icon.s < prev    next >
Text File  |  1995-10-01  |  8KB  |  408 lines

  1. ;TOSAAAABCBOAAAABLHCPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPNCHH
  2.  
  3.     incdir    "include:"
  4.     include    "exec/types.i"
  5.     include    "exec/ports.i"
  6.     include    "exec/execbase.i"
  7.     include    "exec/memory.i"
  8.     include    "workbench/workbench.i"
  9.     include    "libs/dos.i"
  10.     include    "libs/exec.i"
  11.     include    "dos/dos.i"
  12.     incdir    "ups:"
  13.     include    "ups.i"
  14.  
  15.  
  16.  
  17. Start    moveq    #0,d0
  18.     rts
  19. .end    blk.b    32-(.end-Start)
  20.     dc.l    pfsControlLong
  21.     dc.l    0            ; pointer to next patcher
  22.     dc.l    0            ; pointer to prev patcher
  23.     dc.l    UPSMainVersion        ; minimum version of UPS to start
  24.     dc.l    UPSMainVersion        ; version of UPS which was used
  25.                     ; while patcher was developed
  26.     dc.l    PatcherName        ; pointer to name of patcher
  27.     dc.w    0,0            ; version
  28.     dc.l    CoderName        ; pointer to name of programmer
  29.     dc.l    VerString        ; pointer to $VER: string
  30.     dc.l    PatcherIDString        ; listview entry
  31.     dc.l    pfsDisableable        ; flags
  32.     dc.l    0            ; status of flags
  33. execbase
  34.     dc.l    0            ; exec base
  35. intbase    dc.l    0            ; intuition base
  36. gadtbase
  37.     dc.l    0            ; gadtools base
  38. dosbase    dc.l    0            ; dos base
  39. gfxbase    dc.l    0            ; graphics base
  40. cxbase    dc.l    0            ; commodities base
  41. laybase    dc.l    0            ; layers base
  42. upsbase    dc.l    0            ; UPS lib base
  43.     dc.l    init            ; pointer to init routine
  44.     dc.l    0            ; pointer to exit routine
  45.     dc.l    0            ; pointer to prefs routine
  46.     dc.l    0            ; pointer to cx keys to call prefs rout
  47.     dc.l    Resources        ; pointer to structure of requested
  48.                         ; opened resources
  49.     dc.l    Patch1            ; pointer to structure for patches
  50.     dc.l    pls1            ; pointer to pls structure
  51.     dc.l    0            ; pointer to main UPS msg port
  52.     dc.l    0            ; pointer to rexx port
  53.     dc.l    0            ; pointer to pxs structure
  54.     dc.l    0,0,0
  55.     dc.l    pfsControlLong
  56.     dc.l    Start            ; pointer to the beginning of struct
  57.  
  58. PatcherName
  59. PatcherIDString
  60.     dc.b    'Icon Changer',0
  61.     even
  62. CoderName
  63.     dc.b    'Goran Mitrovic',0
  64.     even
  65. VerString
  66.     dc.b    '$VER: Icon Changer 1.0',0
  67.     cnop    0,4
  68.  
  69.  
  70.  
  71. Resources
  72.     dc.l    0            ; pointer to next entry
  73.     dc.l    0            ; pointer to previous entry
  74.     dc.l    rt_Library        ; type of resource
  75.     dc.l    100            ; resource id
  76.     dc.l    0            ; flags
  77.     dc.l    res1name        ; pointer to name of resource
  78. dosbase2
  79.     dc.l    0            ; base of opened resource
  80.     dc.l    0            ; version, if needed
  81.     blk.l    8            ; ...to put in data regs
  82.     dc.l    0            ; user open rout for user type
  83.     dc.l    0            ; user close rout for user type
  84.     dc.l    0            ; pointer to name for user type
  85.     dc.l    0,0
  86.  
  87. res1name
  88.     dc.b    'dos.library',0
  89.     cnop    0,4
  90.  
  91.  
  92.  
  93. Patch1
  94.     dc.l    Patch2            ; pointer to next patch
  95.     dc.l    0            ; pointer to prev patch
  96.     dc.l    0            ; priority, less runs first
  97.     dc.l    Start            ; pointer to parent Patcher
  98.     dc.l    Patch1ID        ; listview entry
  99.     dc.l    Patch1purpose        ; pointer to purpose string
  100.     dc.l    100            ; id of resource to be patched
  101.     dc.l    mpsDisableable+mpsFullPatch    ; flags
  102.     dc.l    0            ; status of flags
  103.     dc.l    Open            ; offset to change
  104.     dc.l    Patch1rout        ; pointer to new routine
  105.     dc.l    0            ; pointer to old routine
  106.     dc.l    0            ; pointer to pns structure
  107.     dc.l    0            ; notified when enabled/disabled
  108.     dc.l    0            ; install rout for user type
  109.     dc.l    0            ; uninstall rout for user type
  110.     dc.l    0            ; pointer to init routine
  111.     dc.l    0            ; pointer to exit routine
  112.     dc.l    pls1            ; pointer to pls structure
  113.     dc.l    0,0,0,0
  114.  
  115.  
  116. Patch1ID
  117. pls1ID    dc.b    'Open()',0            ; 27
  118.     even
  119. Patch1purpose
  120.     dc.b    'improving',0            ; 16
  121.     cnop    0,4
  122.  
  123.  
  124. Patch2
  125.     dc.l    0            ; pointer to next patch
  126.     dc.l    Patch1            ; pointer to prev patch
  127.     dc.l    0            ; priority, less runs first
  128.     dc.l    Start            ; pointer to parent Patcher
  129.     dc.l    Patch2ID        ; listview entry
  130.     dc.l    Patch1purpose        ; pointer to purpose string
  131.     dc.l    100            ; id of resource to be patched
  132.     dc.l    mpsDisableable+mpsFullPatch    ; flags
  133.     dc.l    0            ; status of flags
  134.     dc.l    Close            ; offset to change
  135.     dc.l    Patch2rout        ; pointer to new routine
  136.     dc.l    0            ; pointer to old routine
  137.     dc.l    0            ; pointer to pns structure
  138.     dc.l    0            ; notified when enabled/disabled
  139.     dc.l    0            ; install rout for user type
  140.     dc.l    0            ; uninstall rout for user type
  141.     dc.l    0            ; pointer to init routine
  142.     dc.l    0            ; pointer to exit routine
  143.     dc.l    pls2            ; pointer to pls structure
  144.     dc.l    0,0,0,0
  145.  
  146. Patch2ID
  147. pls2ID    dc.b    'Close()',0            ; 27
  148.     cnop    0,4
  149.  
  150.  
  151. pls1    dc.l    pls2            ; pointer to next link
  152.     dc.l    0            ; pointer to prev link
  153.     dc.l    pls1ID            ; listview string
  154.     dc.l    0            ; pointer to prefs routine
  155.     dc.l    plsDisableable        ; flags
  156.     dc.l    0            ; status
  157.     dc.l    Patch1
  158.     dc.l    0
  159.  
  160.  
  161. pls2    dc.l    0            ; pointer to next link
  162.     dc.l    pls1            ; pointer to prev link
  163.     dc.l    pls2ID            ; listview string
  164.     dc.l    0            ; pointer to prefs routine
  165.     dc.l    plsDisableable        ; flags
  166.     dc.l    0            ; status
  167.     dc.l    Patch2
  168.     dc.l    0
  169.  
  170.     cnop    0,4
  171.  
  172.  
  173. init    movem.l    d0-a6,-(a7)
  174.     move.l    dosbase,a6
  175.     move.l    #icon,d1
  176.     move.l    #parsed,d2
  177.     move.l    #1024,d3
  178.     jsr    ParsePatternNoCase(a6)
  179.     move.l    #temp,d1
  180.     move.l    #parsed2,d2
  181.     move.l    #1024,d3
  182.     jsr    ParsePatternNoCase(a6)
  183.     move.l    4,a6
  184.     lea    wb,a1
  185.     jsr    FindTask(a6)
  186.     move.l    d0,wbtask
  187.     movem.l    (a7)+,d0-a6
  188.     rts
  189.  
  190.  
  191. Patch1rout
  192.     movem.l    d1-a6,-(a7)
  193.     movem.l    d1/d2,-(a7)
  194.     move.l    4,a6
  195.     move.l    wbtask,d0
  196.     cmp.l    ThisTask(a6),d0
  197.     bne.w    old2
  198.  
  199.     move.l    #parsed,d1
  200.     move.l    d1,d2
  201.     move.l    dosbase,a6
  202.     jsr    MatchPatternNoCase(a6)
  203.     tst.b    d0
  204.     beq.s    old2
  205.  
  206.     movem.l    (a7)+,d1/d2
  207.     move.l    #next,-(a7)
  208.     lea    Patch1,a1
  209.     move.l    mps_pns(a1),a1
  210.     move.l    pns_Next(a1),-(a7)
  211.     rts
  212. next    tst.l    d0
  213.     bne.s    change
  214. exit    movem.l    (a7)+,d1-a6
  215.     rts
  216.  
  217. old2    movem.l    (a7)+,d0/d1
  218. old    movem.l    (a7)+,d1-a6
  219.     move.l    a1,d0
  220.     lea    Patch1,a1
  221.     move.l    mps_pns(a1),a1
  222.     move.l    pns_Next(a1),-(a7)
  223.     move.l    d0,a1
  224.     rts
  225.  
  226.  
  227. change    move.l    d0,-(a7)            ; fh
  228.     move.l    4,a6
  229.     move.l    #fib_SIZEOF,d0
  230.     move.l    #MEMF_PUBLIC,d1
  231.     jsr    AllocVec(a6)
  232.     tst.l    d0
  233.     beq.w    .exit
  234.     move.l    (a7)+,d1            ; -
  235.     move.l    d1,-(a7)
  236.     move.l    d0,-(a7)            ; fh, fib
  237.     move.l    d0,d2
  238.     move.l    dosbase,a6
  239.     jsr    ExamineFH(a6)
  240.     tst.w    d0
  241.     beq.w    .exit2
  242.     move.l    (a7)+,a1            ; fh
  243.     move.l    fib_Size(a1),-(a7)        ; fh, len
  244.     move.l    4,a6
  245.     jsr    FreeVec(a6)
  246.     move.l    (a7)+,d0
  247.     move.l    d0,-(a7)
  248.     move.l    #MEMF_PUBLIC,d1
  249.     jsr    AllocVec(a6)
  250.     tst.l    d0
  251.     beq.w    .exit
  252.     move.l    (a7)+,d3
  253.     move.l    (a7)+,d1
  254.     move.l    d0,d2
  255.     move.l    d1,-(a7)
  256.     move.l    d2,-(a7)
  257.     move.l    d3,-(a7)            ; fh, buffer, len, fh
  258.     move.l    dosbase,a6
  259.     jsr    Read(a6)
  260.     cmp.l    #-1,d0
  261.     beq.w    .exit3
  262.  
  263.  
  264.  
  265. .wait    tst.l    semaphore
  266.     bne.s    .wait
  267.     move.l    #1,semaphore
  268.     lea    count,a2
  269.     lea    name2,a3
  270.     moveq    #1,d1
  271.     moveq    #7,d7
  272. .loop    move.b    (a2),d0
  273.     add.b    d1,d0
  274.     cmp.b    #16,d0
  275.     blt.s    .noover
  276.     move.b    #0,d0
  277.     add.b    #1,1(a2)
  278. .noover    move.b    d0,(a2)
  279.     add.b    #'a',d0
  280.     move.b    d0,(a3)+
  281.     addq.l    #1,a2
  282.     moveq    #0,d1
  283.     dbra    d7,.loop
  284.     move.l    #name,d1
  285.     move.l    #MODE_NEWFILE,d2
  286.  
  287.     move.l    #.next,-(a7)
  288.     lea    Patch1,a1
  289.     move.l    mps_pns(a1),a1
  290.     move.l    pns_Next(a1),-(a7)
  291.     rts
  292. .next
  293.     move.l    #0,semaphore
  294.     tst.l    d0
  295.     beq.s    .exit3
  296.  
  297.     move.l    d0,d1
  298.     move.l    (a7)+,d3            ; fh, buffer
  299.     move.l    (a7)+,d2            ; fh
  300.     move.l    (a7)+,d4
  301.     move.l    d0,-(a7)            ; newfh
  302.     move.l    d2,-(a7)            ; newfh, buffer
  303.     move.l    d4,-(a7)            ; newfh, buffer, oldfh
  304.     jsr    Write(a6)
  305.     cmp.l    #-1,d0
  306.     beq.s    .exit4
  307.  
  308.     move.l    (a7)+,d1            ; newfh, buffer
  309.     jsr    Close(a6)
  310.     move.l    4,a6
  311.     move.l    (a7)+,a1
  312.     jsr    FreeVec(a6)
  313.     move.l    (a7)+,d1
  314.     move.l    d1,-(a7)
  315.     moveq    #0,d2
  316.     move.l    #OFFSET_BEGINNING,d3
  317.     move.l    dosbase,a6
  318.     jsr    Seek(a6)
  319.     bra.s    .exit
  320.  
  321.  
  322. .exit4    move.l    (a7)+,d0
  323.     move.l    (a7)+,d1
  324.     move.l    (a7)+,d2
  325.     bra.s    .exit1
  326. .exit3    move.l    4,a6
  327.     move.l    (a7)+,d0
  328.     move.l    (a7)+,a1
  329.     jsr    FreeVec(a6)
  330.     bra.s    .exit
  331. .exit2    move.l    4,a6
  332.     move.l    (a7)+,a1
  333.     jsr    FreeVec(a6)
  334. .exit    move.l    (a7)+,d0
  335. .exit1    bra.w    exit
  336.  
  337.  
  338.  
  339. Patch2rout
  340.     movem.l    d1-a6,-(a7)
  341.     move.l    d1,-(a7)
  342.     move.l    4,a6
  343.     move.l    wbtask,d0
  344.     cmp.l    ThisTask(a6),d0
  345.     bne.w    .old4
  346.  
  347.     move.l    #name4,d2
  348.     move.l    #15,d3
  349.     move.l    dosbase,a6
  350.     jsr    NameFromFH(a6)
  351.     tst.w    d0
  352.     beq.s    .old4
  353.  
  354.     move.l    #parsed2,d1
  355.     move.l    #name4,d2
  356.     jsr    MatchPatternNoCase(a6)
  357.     tst.b    d0
  358.     beq.s    .old4
  359.  
  360.     move.l    (a7)+,d1
  361.     move.l    #.next,-(a7)
  362.     lea    Patch2,a1
  363.     move.l    mps_pns(a1),a1
  364.     move.l    pns_Next(a1),-(a7)
  365.     rts
  366. .next    tst.l    d0
  367.     bne.s    .change
  368. .exit    movem.l    (a7)+,d1-a6
  369.     rts
  370.  
  371. .old4    move.l    (a7)+,d1
  372. .old3    movem.l    (a7)+,d1-a6
  373.     move.l    a1,d0
  374.     lea    Patch2,a1
  375.     move.l    mps_pns(a1),a1
  376.     move.l    pns_Next(a1),-(a7)
  377.     move.l    d0,a1
  378.     rts
  379.  
  380.  
  381. .change    move.w    #$ffff,d7
  382. .aa    move.w    #$fff,$dff180
  383.     dbra    d7,.aa
  384.     rts
  385.  
  386.  
  387.  
  388.  
  389. icon    dc.b    '#?.icon',0
  390. wb    dc.b    'Workbench',0
  391. name    dc.b    'ram:tempicon'
  392. name2    dc.l    0,0
  393.     dc.b    0
  394. temp    dc.b    'tempicon#?',0
  395. name3    dc.b    'ram:'
  396. name4    blk.b    15
  397.     dc.b    0
  398.     even
  399.  
  400.     SECTION    aa,BSS_p
  401. wbtask    ds.l    1
  402. semaphore
  403.     ds.l    1
  404. count    ds.l    2
  405.     ds.l    1
  406. parsed    ds.b    1024
  407. parsed2    ds.b    1024
  408.